<%@page import="java.awt.print.Printable"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<meta HTTP-EQUIV="pragma" CONTENT="no-cache">
<meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<meta HTTP-EQUIV="expires" CONTENT="0">
<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragrma","no-cache");
response.setDateHeader("Expires",0);
%>
<title>_${customer.customerName}_执行拣货任务</title>
<script language="javascript" type="text/javascript" src="${ctx}/static/datepicker/WdatePicker.js"></script>
<script type="text/javascript">
  
  $(function() {
		$("#queryForm").validate(); 
		
		var status='${task.status}';
		if(status=='3'){
			 $("#btn_complete").attr("disabled", true);
			 $("#btn_complete").attr("class", "btn");
			 
			 $("#btn_complete_1").attr("disabled", true);
			 $("#btn_complete_1").attr("class", "btn");
		}
  });
  
  //获取拣货信息
  function getInfo(stockInfo,part) {
      
       var stockInfoArray=stockInfo.split(";");
       var stockInfo=stockInfoArray[0];
       var infoArray=stockInfo.split("_");
       
       var temp='';
       if( part=='sku' ){
          temp=infoArray[2];
       }else if(part=='stockCode'){
         temp=infoArray[0];
       }else if(part=='num'){
         temp=infoArray[3];
       }else if(part=='boxCode'){
         temp=infoArray[1];
       }
       return temp;
	}
  
   //完成拣货任务
   function complete(){
	   $("#btn_complete").attr("disabled", true);
	   var taskId='${task.id}';
       $.ajax({
			type:'post',
			url:'${ctx}/pickTask/ajaxCompletePickTask',
			data:{
				taskId:taskId
			},
			dataType:'json',
			success:function(data) {
			    if(data==true){
			      alert("此任务已完成拣货！");
			      
			      $("#btn_complete").attr("disabled", true);
			      $("#btn_complete").html("已完成拣货");
			      $("#btn_complete").attr("class", "btn");
			      $("#btn_close").trigger("click");
			      location.reload();
				  
			    }else{
			      $("#btn_complete").attr("disabled", false);
			      alert("网络繁忙，请稍后重试...");
			    }
			},
			error:function() {
				$("#btn_complete").attr("disabled", false);
				alert("网络繁忙，请稍后重试...");
			}
	   });
       
   }
   
</script>
</head>

<body>

<section class="content">
<div class="row">
		<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-edit"></i>
					<h3 class="box-title">任务信息</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
				
    <table class="table table-striped table-bordered table-condensed" style="margin-top: 0px;">
<!-- 		<thead> -->
<!-- 			<th style="vertical-align: middle; color: white; " colspan="12" bgcolor="#8EB4CB">任务信息</th> -->
<!-- 		</thead> -->
		<thead><tr>
		        <th>商家</th>
		        <th>仓库</th>
		        <th>批次编号</th>
			    <th>任务编号</th>
			    <th>订单类型</th>
			    <th>运单类型</th>
			    <th>作业类型</th>
			    <th>订单数量（条）</th>
			    <th>任务状态</th>
			    <th>操作</th>
			</tr>
	   </thead>
	   <tr>
	      <td>${task.customer.customerName}</td>
	      <td>${task.warehouse.groupName}</td>
	       <td>${task.batchCode}</td>
	      <td>${task.taskCode}</td>
	      <td>
	        <c:if test="${task.pickType eq 'single'}">单件</c:if>
	        <c:if test="${task.pickType eq 'multi'}">多件
	        </c:if>
	      </td>
	      <td>
	          <c:if test="${task.billType eq 'cbill'}">普通运单</c:if>
			  <c:if test="${task.billType eq 'ebill'}">电子运单</c:if>
	      </td>
	      <td>
			     <c:if test="${task.flowType eq 'prePrint'}">预先打单</c:if>
			     <c:if test="${task.flowType eq 'intimePrint'}">及时打单</c:if>
		  </td>
	      <td>${task.orderQty}</td>
	      <td>
	        <!-- 任务状态( 1.创建任务 2.已分配拣货任务 3.已拣货 4. 已分配灯光拣选任务 5.已经灯光拣选 6.已分配包装任务 7.已包装 8.已分配发货任务 9.已发货 10.灯光拣选进行中.. 11.推车拣选进行中.. 12.拣货中...) -->
			     <c:if test="${task.status eq '1'}"><font color=blue>创建任务</font></c:if>
			     <c:if test="${task.status eq '2'}"><font color=blue>已分配拣货任务</font></c:if>
			     <c:if test="${task.status eq '3'}"><font color=blue>已拣货</font></c:if>
			     <c:if test="${task.status eq '4'}"><font color=blue>已分配灯光拣选任务</font></c:if>
			     <c:if test="${task.status eq '5'}"><font color=blue>已经灯光拣选</font></c:if>
			     <c:if test="${task.status eq '6'}"><font color=blue>已分配包装任务</font></c:if>
			     <c:if test="${task.status eq '7'}"><font color=blue>已包装</font></c:if>
			     <c:if test="${task.status eq '8'}"><font color=blue>已分配发货任务</font></c:if>
			     <c:if test="${task.status eq '9'}"><font color=blue>已发货</font></c:if>
			     <c:if test="${task.status eq '10'}"><font color=blue>灯光拣选进行中..</font></c:if>
			     <c:if test="${task.status eq '11'}"><font color=blue>推车拣选进行中..</font></c:if>
			     <c:if test="${task.status eq '12'}"><font color=blue>拣货中..</font></c:if>

	     </td>
	      <td>
	            <a href="${ctx}/pickTask/v2_toPrintPickInfo_single/${task.taskCode}"  role="button" class="btn btn-primary" >导出拣货单</a>
	         
	            <c:if test="${task.status eq '2'}">
		            <a href="${ctx}/pickTask/v2_toPickPage/${task.taskCode}" id="btn_complete_1" class="btn btn-primary">
		                <c:if test="${task.flowType eq 'prePrint' }">拣货(配单)</c:if>
		                <c:if test="${task.flowType eq 'intimePrint' }">拣货</c:if>
		            </a>
	            </c:if>
	            
	            <c:if test="${task.status eq '12'}">
		            <a href="${ctx}/pickTask/v2_toPickPage/${task.taskCode}" id="btn_complete_1" class="btn btn-primary">
		                <c:if test="${task.flowType eq 'prePrint' }">继续拣货(配单)</c:if>
		                <c:if test="${task.flowType eq 'intimePrint' }">继续拣货</c:if>
		            </a>
	            </c:if>
	            
	            
	         
	      </td>
	   </tr>
	</table>

</div>
	</div>
	</div>
	</div>
	
<div class="row">
		<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-edit"></i>
					<h3 class="box-title">订单信息</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
				
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
<!-- 	    <thead> -->
<!-- 			<th style="vertical-align: middle; color: white; " colspan="11" bgcolor="#8EB4CB">订单信息</th> -->
<!-- 		</thead> -->
		<thead><tr>
			    <th>序号</th>
			    <th>订单编号</th>
			    <th>SKU编号</th>
			    <th>仓库</th>
			    <th>库位</th>
			    <th>箱号</th>
			    <th>数量</th>
			</tr></thead>
		<tbody>
		<c:forEach items="${orderList}" var="o" varStatus="i">
			<tr>
			   <td>${i.count}</td>
			   <td>${o.order.ordeno}</td>
			   <td><script type="text/javascript">document.write(getInfo('${o.stockInfo}','sku'));</script></td>
			   <td>${task.warehouse.groupName}</td>
			   <td><script type="text/javascript">document.write(getInfo('${o.stockInfo}','stockCode'));</script></td>
			   <td><script type="text/javascript">document.write(getInfo('${o.stockInfo}','boxCode'));</script></td>
			   <td><script type="text/javascript">document.write(getInfo('${o.stockInfo}','num'));</script></td>
			</tr>
		</c:forEach>
		</tbody>
	</table>

</div></div></div></div>
</section>
</body>
</html>
